/*
 * @Author: llch
 * @Date: 2020-08-05 15:22:41
 * @LastEditTime: 2020-08-13 08:35:20
 * @LastEditors: Please set LastEditors
 * @Description: 关卡对象，提供操作关卡数据的方法
 * @FilePath: \shici_demo\assets\Script\game\obj\level.ts
 */

export class Level {
    // 全局单例
    public static readonly Instance: Level = new Level();
    private _idiomsInfo: JSON = undefined;                // 所有的数据
    private _poemsInfo: JSON = undefined;
    public levelLen: number = undefined;

    public idiomInfo: JSON = undefined;                   // 某一关的数据
    public poemInfo: JSON = undefined;

    // 构造函数
    private constructor() {}

    public init(idiomsInfo: JSON, poemsInfo: JSON, levelLen: number) {
        this._idiomsInfo = idiomsInfo;
        this._poemsInfo = poemsInfo;
        this.levelLen = levelLen;
    }

    public getLevelData(level: number): void {
        let poimId: number = this._idiomsInfo[level].poemId;
        this.idiomInfo = this._idiomsInfo[level];
        this.poemInfo = this._poemsInfo[poimId];
    }
}

// 导出
export const Lv = Level.Instance;